#include "irc_nick_filter.h"
#include "irc_line.h"
#include <stdio.h>

irc_nick_filter::irc_nick_filter( const std::string _nick, boost::function<void(std::string)> func ) : irc_base_filter( "Irc Nick Filter" ), nick_func( func )
{
	nick = _nick;
}


irc_nick_filter::~irc_nick_filter(void)
{}

void irc_nick_filter::process( irc_line *line )
{
	if( line->getParams().size() == 0 )
		forward( line );

	int check = line->getParams()["nick"].compare( nick );

	printf( "Checking nick against %s\n", nick.c_str() );

	if( check != 0 )
	{
		printf( "Incorrect: %s\n", line->getParams()["nick"].c_str() );
	}
	else
	{
		printf( "Correct: %s\n", line->getParams()["nick"].c_str() );

		nick_func( line->getParams()["nick"] );
	}

	forward( line );
}
